In [2]:
import pygp
import numpy as np
In [63]:
data = np.load('xy.npz')
X = data['X']
y = data['y']
print X
print y
In [17]:
gp = pygp.BasicGP(sn=.1, sf=1, ell=.1, mu=0)
gp.add_data(X, y)
#gp.add_data(X, y)
In [58]:
print gp.data[0].shape
print gp.ndata
In [20]:
from scipy.optimize import minimize, rosen, rosen_der
In [26]:
x0 = [1.3, 0.7, 0.8, 1.9, 1.2]
Nelder Mead
In [27]:
res = minimize(rosen, x0, method='Nelder-Mead')
res.x
Out[27]:
BFGS
In [28]:
res = minimize(rosen, x0, method='BFGS', jac=rosen_der, options={'gtol': 1e-6, 'disp': True})
res.x
Out[28]:
BFGS with callback
In [30]:
X_y = ([], [])
def callbackF(Xi):
global X_y
X_y[0].append(Xi)
X_y[1].append(rosen(Xi))
res = minimize(rosen, x0, method='BFGS',
jac=rosen_der,
options={'gtol': 1e-6, 'disp': True}, callback=callbackF)
res.x
Out[30]:
In [32]:
X, y = X_y
In [36]:
from scipy.spatial import ConvexHull
In [46]:
import matplotlib.pyplot as plt
%matplotlib inline
In [49]:
X = np.array(X)
y = np.array(y)
print X.shape, y.shape
In [50]:
hull = ConvexHull(X)
In [52]:
hull.vertices.shape
Out[52]:
In [55]:
points = np.random.rand(30, 2)
hull = ConvexHull(points)
hull.vertices
Out[55]:
In [56]:
plt.plot(points[:,0], points[:,1], 'o')
plt.plot(points[hull.vertices,0], points[hull.vertices,1], 'ro')
Out[56]:
In [ ]:
In [ ]: